﻿// <copyright file="CharactersPublic.cs" company="Gravity Age Studios">
// Code released under the MIT license (see License.txt).
// </copyright>
// <author>Vicente Cartas Espinel</author>
// <email>vicente.cartas@gmail.com</email>
namespace LightSwitchApplication
{
    using Microsoft.LightSwitch.Presentation.Extensions;

    public partial class CharactersPublic
    {
        #region View Character

        partial void ViewDetails_CanExecute(ref bool result)
        {
            result = this.Collection.SelectedItem != null &&
                    (this.Collection.SelectedItem.HasPublicInformation == true ||
                     this.Collection.SelectedItem.Portrait != null ||
                     this.Domains.Count > 0 ||
                     this.Lieutenants.Count > 0);
        }

        partial void ViewDetails_Execute()
        {
            this.FindControl("ModalWindow").DisplayName = string.Format("View {0} details", this.Collection.SelectedItem.Name);
            this.OpenModalWindow("ModalWindow");
        }

        partial void SubmitModalWindow_Execute()
        {
            this.CloseModalWindow("ModalWindow");
        }

        #endregion

        #region View Domain

        partial void ViewDomainDetail_CanExecute(ref bool result)
        {
            result = this.Domains.SelectedItem != null;
        }

        partial void ViewDomainDetail_Execute()
        {
            this.Application.ShowDomainViewPlayer(this.Domains.SelectedItem.Id);
        }

        #endregion
    }
}
